abs_start_time=getsecs;
for tr=1:20
    tic
    while toc<2
        [keyIsDown,secs,keyCode] = KbCheck; % Warning: mxSetLogical is deprecated and will not be supported in the future. Please refer to the Release Notes for information on updating your code
        %warning on MATLAB:DeprecatedLogicalAPI
        if keyIsDown==1
            if lastkeyCode~=keyCode % anti hammering
                keyCode=max([0;find(keyCode, 1 )]);
                switch keyCode
                    case 53% INT_5 on pcwin
                        fprintf('keyCode: %d: TRtrigger:  %f lastkeyCode %d\n',keyCode,(getsecs-abs_start_time)*1000,lastkeyCode);
                        %Eyelink('message', 'keyCode: %d: TRtrigger:  %f',keyCode,(getsecs-abs_start_time)*1000);%just like printf(). Only chars and ints allowed in arguments!
                    case 49 % keyboard 1! %blue(left) button on right box
                        fprintf('keyCode: %d: Left:  %f lastkeyCode %d\n',keyCode,(getsecs-abs_start_time)*1000,lastkeyCode);
                        %Eyelink('message', 'keyCode: %d: Left: %f ',keyCode,(getsecs-abs_start_time)*1000);%just like printf(). Only chars and ints allowed in arguments!
                        %case 50 % keyboard 2@
                        %case 51 %keyboard 3#
                    case 52 % keyboard 4$ %red(right) button on right box
                        fprintf('keyCode: %d: Right:  %f lastkeyCode %d\n',keyCode,(getsecs-abs_start_time)*1000,lastkeyCode);
                        %5551Eyelink('message', 'keyCode: %d: Right: %f',keyCode,(getsecs-abs_start_time)*1000);%just like printf(). Only chars and ints allowed in arguments!
                end
                lastkeyCode=keyCode;            
            end  % && lastkeyCode==0
        else
            lastkeyCode=0;% anti hammering
       end %if keyIsDown==1
    end %while toc<2
end